package cn.tedu.dfxd.controller;

import cn.tedu.dfxd.entity.Item;
import cn.tedu.dfxd.mapper.ItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author DBX
 * @effect
 * @date 2022/04/18/14:31
 */
@RestController
@CrossOrigin
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private ItemMapper itemMapper;
    @GetMapping("/recommend")
    public List<Item> findItem(){
       return itemMapper.findItem();
    }

    @GetMapping("/recommendRXD")
    public Item findItemRXD(){
        return itemMapper.findItemRXD();
    }


    @GetMapping("/recommendLimit")
    public List<Item> recommendLimit(){
        return itemMapper.recommendLimit();
    }


    @GetMapping("/recommendDetails/{id}")
    public Item recommendDetails(@PathVariable Integer id){

       Item item = itemMapper.recommendDetails(id);
       item.setItemDesc(itemMapper.findItemIntroduce(id));
       return item;
    }
}
